<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\admin\model;
use think\Model;

/**
 * Description of Group
 *
 * @author HuangLuSen
 */
class Group extends Model {
    /**
     * status修改器
     * @param $value
     * @param $data
     * @return mixed
     */
    public function getStatusTextAttr($value, $data)
    {
       $status = [1=>'<span class="label label-success">正常</span>',0=>'<span class="label label-danger">禁用</span>'];
        return $status[$data['status']];
    }

    /**
     * 关联部门模型
     * @return $this
     */
    public function depar(){
        return $this->belongsTo('depar','depar_id','id',[],'LEFT')->field('name,id');
    }

    /**
     * 关联地区模型
     * @return $this
     */
    public function dq(){
        return $this->belongsTo('dq','dq_id','id',[],'LEFT')->field('name,id');
    }
}
